<?php


namespace Drupal\shushengyuan\Schemas;


use Drupal\mxm_article\Entity\MxmArticle;

class ArticleItem extends AbstractBaseModel {

  protected function getEntityType() {
    return 'mxm_article';
  }

  protected function setValue() {
    if ($this->entity instanceof MxmArticle) {
      $value = [
        'id' => (int) $this->entity->id,
        'title' => (string) $this->entity->title,
        'summary' => (string) $this->entity->summary,
        'author' => UserAuthor::init($this->entity->uid),
        'created' => $this->formatDate($this->entity->created, 'Y-m-d H:i'),
        'body' => $this->wrapper->field_body->value()['safe_value'],
      ];
      $this->merge($value);
    }
  }

}
